<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Resolve lifecycle policy execution errors | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'index-lifecycle-error-handling.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/index-lifecycle-error-handling.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/index-lifecycle-error-handling.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/index-lifecycle-error-handling.html" rel="nofollow" target="_blank">../en/index-lifecycle-error-handling.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="index-lifecycle-management.html">ILM: Manage the index lifecycle</a></span>
»
<span class="breadcrumb-node">Resolve lifecycle policy execution errors</span>
</div>
<div class="navheader">
<span class="prev">
<a href="set-up-lifecycle-policy.html">« Configure a lifecycle policy </a><a id="ilm-policy-definition"></a>
</span>
<span class="next">
<a href="start-stop-ilm.html">Start and stop index lifecycle management »</a>
</span>
</div>
<div class="chapter xpack">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="index-lifecycle-error-handling"></a>Resolve lifecycle policy execution errors<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ilm/error-handling.asciidoc">edit</a><a class="xpack_tag" href="https://www.elastic.co/subscriptions"></a>
</h2>
</div></div></div>
<p>When ILM executes a lifecycle policy, it’s possible for errors to occur
while performing the necessary index operations for a step.
When this happens, ILM moves the index to an <code class="literal">ERROR</code> step.
If {ilm-init] cannot resolve the error automatically, execution is halted
until you resolve the underlying issues with the policy, index, or cluster.</p>
<p>For example, you might have a <code class="literal">shrink-index</code> policy that shrinks an index to four shards once it
is at least five days old:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">PUT _ilm/policy/shrink-index
{
  "policy": {
    "phases": {
      "warm": {
        "min_age": "5d",
        "actions": {
          "shrink": {
            "number_of_shards": 4
          }
        }
      }
    }
  }
}</pre>
</div>
<div class="console_widget" data-snippet="snippets/1127.console"></div>
<p>There is nothing that prevents you from applying the <code class="literal">shrink-index</code> policy to a new
index that has only two shards:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">PUT /myindex
{
  "settings": {
    "index.number_of_shards": 2,
    "index.lifecycle.name": "shrink-index"
  }
}</pre>
</div>
<div class="console_widget" data-snippet="snippets/1128.console"></div>
<p>After five days, ILM attempts to shrink <code class="literal">myindex</code> from two shards to four shards.
Because the shrink action cannot <em>increase</em> the number of shards, this operation fails
and ILM moves <code class="literal">myindex</code> to the <code class="literal">ERROR</code> step.</p>
<p>You can use the <a class="xref" href="ilm-explain-lifecycle.html" title="Explain lifecycle API">ILM Explain API</a> to get information about
what went wrong:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET /myindex/_ilm/explain</pre>
</div>
<div class="console_widget" data-snippet="snippets/1129.console"></div>
<p>Which returns the following information:</p>
<div class="pre_wrapper lang-console-result">
<pre class="programlisting prettyprint lang-console-result">{
  "indices" : {
    "myindex" : {
      "index" : "myindex",
      "managed" : true,
      "policy" : "shrink-index",                <a id="CO435-1"></a><i class="conum" data-value="1"></i>
      "lifecycle_date_millis" : 1541717265865,
      "age": "5.1d",                            <a id="CO435-2"></a><i class="conum" data-value="2"></i>
      "phase" : "warm",                         <a id="CO435-3"></a><i class="conum" data-value="3"></i>
      "phase_time_millis" : 1541717272601,
      "action" : "shrink",                      <a id="CO435-4"></a><i class="conum" data-value="4"></i>
      "action_time_millis" : 1541717272601,
      "step" : "ERROR",                         <a id="CO435-5"></a><i class="conum" data-value="5"></i>
      "step_time_millis" : 1541717272688,
      "failed_step" : "shrink",                 <a id="CO435-6"></a><i class="conum" data-value="6"></i>
      "step_info" : {
        "type" : "illegal_argument_exception",  <a id="CO435-7"></a><i class="conum" data-value="7"></i>
        "reason" : "the number of target shards [4] must be less that the number of source shards [2]"
      },
      "phase_execution" : {
        "policy" : "shrink-index",
        "phase_definition" : {                  <a id="CO435-8"></a><i class="conum" data-value="8"></i>
          "min_age" : "5d",
          "actions" : {
            "shrink" : {
              "number_of_shards" : 4
            }
          }
        },
        "version" : 1,
        "modified_date_in_millis" : 1541717264230
      }
    }
  }
}</pre>
</div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO435-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p>The policy being used to manage the index: <code class="literal">shrink-index</code></p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO435-2"><i class="conum" data-value="2"></i></a></p>
</td>
<td align="left" valign="top">
<p>The index age: 5.1 days</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO435-3"><i class="conum" data-value="3"></i></a></p>
</td>
<td align="left" valign="top">
<p>The phase the index is currently in: <code class="literal">warm</code></p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO435-4"><i class="conum" data-value="4"></i></a></p>
</td>
<td align="left" valign="top">
<p>The current action: <code class="literal">shrink</code></p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO435-5"><i class="conum" data-value="5"></i></a></p>
</td>
<td align="left" valign="top">
<p>The step the index is currently in: <code class="literal">ERROR</code></p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO435-6"><i class="conum" data-value="6"></i></a></p>
</td>
<td align="left" valign="top">
<p>The step that failed to execute: <code class="literal">shrink</code></p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO435-7"><i class="conum" data-value="7"></i></a></p>
</td>
<td align="left" valign="top">
<p>The type of error and a description of that error.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO435-8"><i class="conum" data-value="8"></i></a></p>
</td>
<td align="left" valign="top">
<p>The definition of the current phase from the <code class="literal">shrink-index</code> policy</p>
</td>
</tr>
</table>
</div>
<p>To resolve this, you could update the policy to shrink the index to a single shard after 5 days:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">PUT _ilm/policy/shrink-index
{
  "policy": {
    "phases": {
      "warm": {
        "min_age": "5d",
        "actions": {
          "shrink": {
            "number_of_shards": 1
          }
        }
      }
    }
  }
}</pre>
</div>
<div class="console_widget" data-snippet="snippets/1130.console"></div>
<h3>
<a id="_retrying_failed_lifecycle_policy_steps"></a>Retrying failed lifecycle policy steps<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ilm/error-handling.asciidoc">edit</a>
</h3>
<p>Once you fix the problem that put an index in the <code class="literal">ERROR</code> step,
you might need to explicitly tell ILM to retry the step:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">POST /myindex/_ilm/retry</pre>
</div>
<div class="console_widget" data-snippet="snippets/1131.console"></div>
<p>ILM subsequently attempts to re-run the step that failed.
You can use the <a class="xref" href="ilm-explain-lifecycle.html" title="Explain lifecycle API">ILM Explain API</a> to monitor the progress.</p>
</div>
<div class="navfooter">
<span class="prev">
<a href="set-up-lifecycle-policy.html">« Configure a lifecycle policy </a><a id="ilm-policy-definition"></a>
</span>
<span class="next">
<a href="start-stop-ilm.html">Start and stop index lifecycle management »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>